class MOM1:
    def __init__(self,conn):
        self.conn=conn
        self.count=0
        self.pretimekey=None
        self.fx=None
    def oncalc(self,a,b,timekey=None):
        if a!=None:
            if b!=None:
                if self.fx==None:
                    if a>b:
                        self.fx = 1
                        self.count=1
                    else:
                        self.fx = -1
                        self.count=1
                else:
                    if self.fx<=-1:
                        if a>b:
                            if self.count > self.conn:
                                self.fx = 2
                            else:
                                self.fx=1
                            self.count = 1

                        else:
                            self.fx = -1
                            self.count=self.count+1
                    elif self.fx>=1:
                        if a<b:
                            if self.count > self.conn:
                                self.fx = -2
                            else:
                                self.fx = -1
                            self.count = 1
                        else:
                            self.fx = 1
                            self.count=self.count+1

        return self.fx